package com.nuc.list1;

import java.util.ArrayList;
import java.util.List;

/**
 * Time    : 2023/3/30 10:09
 * Author  : 王摇摆
 * FileName: Demo4.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Demo4 {
    public static void main(String[] args) {
        List<String> names = new ArrayList<>();
        names.add("刘备");
        names.add("关羽");
        names.add("张飞");
        names.add("刘备");
        names.add("张飞");

        System.out.println("The value of the List is:");
        for (String name : names) {
            System.out.print(name + "\t");
        }
        System.out.println();
        System.out.println("---------");


        System.out.println(names.indexOf("刘备"));
        System.out.println(names.lastIndexOf("刘备"));
        System.out.println(names.indexOf("张飞"));
        System.out.println(names.lastIndexOf("张飞"));

    }
}
